package com.entity;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "_Quatation")
public class Quatation implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Column(length = 50)
	private String brand; // 品牌

	private Integer disparity;// 材料进销差价率
	@Id
	@GeneratedValue
	private Integer id; // 零件编号
	private Double inPrice;// 材料进价
	@Column(length = 50)
	private String name; // 零件名称
	/*
	 * ##这是一个坑#### 材料进价 ，材料进销差价率，材料销售价 ------
	 * 这三项可之间有联系，可以互相转化，根据数据库三大范式设计原则，可以省略其中一列
	 */
	@Transient
	private Double outPrice;// 材料销售价
	@Column(length = 50)
	private String production;// 产地

	public Quatation() {
		super();
	}

	public Quatation(String name, Double inPrice, Integer disparity, String production, String brand) {
		super();
		this.name = name;
		this.inPrice = inPrice;
		this.disparity = disparity;
		this.production = production;
		this.brand = brand;
	}
	// 以下getter setter
	public String getBrand() {
		return brand;
	}

	public Integer getDisparity() {
		return disparity;
	}

	public Integer getId() {
		return id;
	}

	public Double getInPrice() {
		return inPrice;
	}

	public String getName() {
		return name;
	}

	// 获取材料销售价
	public Double getOutPrice() {
		BigDecimal b = new BigDecimal(inPrice * (100 + disparity) / 100);
		return b.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
	}

	public String getProduction() {
		return production;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public void setDisparity(Integer disparity) {
		this.disparity = disparity;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setInPrice(Double inPrice) {
		this.inPrice = inPrice;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setOutPrice(Double outPrice) {
		this.outPrice = outPrice;
	}

	public void setProduction(String production) {
		this.production = production;
	}

}
